<%@ taglib prefix="p" uri="/WEB-INF/tld/privilege.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>软件项目列表</title>
<base href="<%=basePath%>" />
<%@ include file="../../list_include.jsp"%>
<script language="JavaScript" type="text/javascript"src="<%=basePath%>js/my97/WdatePicker.js" defer="defer"></script>
<base target="_self" />
<style type="text/css">
fieldset,table,tr,td {
	margin: 0;
	padding: 0;
}

td {
	padding: 0 5px 0 10px;
}

form label {
	font-weight: bold;
}

form input {
	width: 200px;
}

#riskTable {
	margin: 5px 0;
}
</style>

<script type="text/javascript">
	$(document).ready(function() { 
       	$("#riskTable").tablesorter({theme:'green', widgets:['zebra', "resizable"]});
       	
       	$("#btn_pageUp").click(function(){
			var curPage = $("#curPage").val();
			$("#curPage").val(parseInt(curPage) - 1);
			$("#riskForm").submit();
       	});
       	
       	$("#btn_pageDown").click(function(){
       		var curPage = $("#curPage").val();
			$("#curPage").val(parseInt(curPage) + 1);
			$("#riskForm").submit();
       	});
        
        $("#btn_search").click(function(){
            $("#curPage").val(1);
            $("#riskForm").submit();
        });
        
        $("#btn_clear").click(function(){
            $("#riskType").val('');
            $("#status").val('');
        });
        $("#btn_insert").click(function(){           
            location.href = "<%=basePath%>soft/riskManager/add.do?projectId="+$("#projectId").val();
        });
        
        $("#btn_change").click(function(){
            var page = parseInt($("#selectPage").val());
            var curPage = parseInt($("#curPage").val());
            if(curPage == page) return;
            $("#curPage").val(parseInt(page));
            $("#riskForm").submit();
        });
	});  
	
	function edit(id) {
        var queryString = $("#riskForm").formSerialize();
        queryString = encodeURIComponent(queryString);
        location.href = "<%=basePath%>soft/riskManager/edit.do?id=" + id + "&qs="+ queryString;
	}

	function del(id) {
		if (confirm("确定删除该对象？") != 1)
			return;
		$.get("soft/riskManager/del.do", {
			id : id
		  }, function(data) {
			var result = $.parseJSON(data);
			if (result.code == 1) {
				alert("删除成功!");
				$("#btn_search").click();
			} else {
				alert(result.msg);
			}
		});
	}
    //返回列表页面
    function btn_return(){
	    var qs = $("#qs").val();
    	window.location.href="<%=basePath%>soft/project/list.do?" + qs;
    }
</script>
</head>
<body>
	<div>
		<fieldset>
			<legend>查询条件：</legend>
			<input id="qs" name="qs" type="hidden" value="${qs}" />
				<p id="p_error" style="margin: 10px 10px;">
					<label id="error_label" style="color: red;"></label>
				</p>
			<form id="riskForm" method="get" action="soft/riskManager/list.do">
				<table>
					<tr>
						<td><label for="name">风险类型：</label></td>
						<td><select name="riskType" id="riskType">
								<option value="">--请选择风险类型--</option>
								<c:forEach var="type" items="${riskTypes}">
									<option value="${type.value}"
										<c:if test="${type.value == riskType}">selected</c:if>>${type.name}</option>
								</c:forEach>
						</select></td>
						<td><label for="name">状态：</label></td>
						<td><select name="status" id="status">
								<option value="">--选择状态--</option>
								<c:forEach var="st" items="${riskStatus}" >
									<option value="${st.value}"<c:if test="${st.value == status}">selected</c:if>>${st.name}</option>
								</c:forEach>
						</select></td>
						<td><input type="button" id="btn_search" name="btn_search"
							value="查询" style="width: 80px;" /></td>
						<td><input type="button" id="btn_clear" name="btn_clear"
							value="重置" style="width: 80px;" /></td>
					</tr>
				</table>
				<input type="hidden" name="projectId" id="projectId" value="${projectId }" />
			    <input type="hidden" name="curPage" id="curPage" value="${curPage}" /> 
			    <input type="hidden" name="totalPage" id="totalPage" value="${totalPage}" />
			</form>
		</fieldset>
	</div>
	<div>
		<table id="riskTable" class="tablesorter">
			<thead>
				<tr>
					<th>项目名称</th>
					<th>类型</th>
					<th>状态</th>
					<th>描述</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${riskList}" var="rl" >
					<tr>
						<td >${projectName}</td>
						<td >
							<c:forEach var="type" items="${riskTypes}" >
							    <c:if test="${type.value == rl.riskType }">
							        ${type.name}
							    </c:if>
							</c:forEach>
                        </td>
						<td>
							<c:forEach var="st" items="${riskStatus}" >
								<c:if test="${st.value == rl.status }">
								    ${st.name}
								</c:if>
							</c:forEach>
						</td>
						<td>${rl.description }</td>
						<td>
						    <a href="soft/riskManager/view.do?id=${rl.id}&projectName=${projectName}">查看</a> 
						    <a href="soft/riskManager/edit.do?id=${rl.id}&projectName=${projectName}">修改</a> 
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>
	<div>
	 <div style="float:left;">
       <input id="btn_insert" type="button" value="新增" />
       <input type="button" id="btn_back" value="返回" onclick="btn_return();" style="width: 80px;" />
       
      </div>
		<div style="text-align: right;">
			<c:if test="${curPage <= 1}">
				<input type="button" disabled="disabled" id="btn_pageUp" value="上一页" />
			</c:if>
			<c:if test="${curPage > 1}">
				<input type="button" id="btn_pageUp" value="上一页" />
			</c:if>
			<c:if test="${curPage >= totalPage}">
				<input type="button" id="btn_pageDown" disabled="disabled"
					value="下一页" />
			</c:if>
			<c:if test="${curPage < totalPage}">
				<input type="button" id="btn_pageDown" value="下一页" />
			</c:if>
			 共${totalPage}页/共${totalRecords}条
		    <select id="selectPage"style="width: auto;">
				<c:forEach var="i" begin="1" end="${totalPage}">
					<option id="${i}"
						<c:if test="${i == curPage}">selected="selected"</c:if>>${i}</option>
				</c:forEach>
			</select> <input id="btn_change" type="button" value="转至" />
		</div>
	</div>
</body>
</html>